package com.api.gbhg.zengping.web;

import com.alibaba.fastjson.JSON;
import com.api.gbhg.liwenjun.GBHGConstant;
import com.api.gbhg.zengping.dao.BudgetingListDao;
import com.api.gbhg.zengping.dao.PropertyManagementCostDao;
import com.api.gbhg.zengping.page.PageInfo;
import com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.*;

/**
 * @program: gbhg-oa
 * @author: Mr.zeng
 * @create: 2021-01-26 13:46
 *
 * 预算编制列表查询
 **/

public class BudgetingListAction {
    public static  BudgetingListDao budgetingDao=new BudgetingListDao();
    private final PropertyManagementCostDao rmcd=new PropertyManagementCostDao();
    public static final Logger LOGGER = LoggerFactory.getLogger("gbhg");

    @POST
    @Path("/budgetList")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    public String budgetList(Map<String,Object> map){
        LOGGER.info("进入预算编制列表----");
        PageInfo pageInfo = budgetingDao.getSelectByNdAndDwAndProject2(map);
        return JSON.toJSONString(pageInfo);
    }
    @GET
    @Path("/getProject")
    @Consumes(MediaType.APPLICATION_JSON)
    public String getProject(){
        GBHGConstant.FlowVersionTableEnum[] values = GBHGConstant.FlowVersionTableEnum.values();
        List<String> list=new ArrayList();
        for (int i = 0; i < values.length; i++) {
            String flowName = values[i].getFlowName();
            list.add(flowName.substring(3,flowName.length()-1));
        }
        return JSON.toJSONString(list);
    }

    public static void main(String[] args) {
        Set<String> strings = getIsGDSBProject();
        for (String str:strings
             ) {
            System.out.println(str);
        }
        boolean contains = strings.contains("01");
        System.out.println(contains);
    }

    /**
     * 是否固定申报项目
     * @return
     */
    public static Set<String> getIsGDSBProject(){
        Set<String> hs=new HashSet<>();
        GBHGConstant.FlowVersionTableEnum[] values = GBHGConstant.FlowVersionTableEnum.values();
        for (int i = 0; i < values.length; i++) {
            String flowName = values[i].getFlowType();
           hs.add(flowName);
        }
        return hs;
    }

    public static String getProjectNameReturnType(String xm){
        String type=null;
        if(!Strings.isNullOrEmpty(xm)){
            GBHGConstant.FlowVersionTableEnum[] values = GBHGConstant.FlowVersionTableEnum.values();
            for (int i = 0; i < values.length; i++) {
                String flowName = values[i].getFlowName();
                System.out.println(flowName.substring(3,flowName.length()-1));
                if(xm.equals(flowName.substring(3,flowName.length()-1))){
                    type=values[i].getFlowType();
                }
            }
        }
        return type;
    }
}
